package com.atguigu.realtime.function;

import com.atguigu.realtime.common.GmallConstant;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

/**
 * @Author lizhenchao@atguigu.cn
 * @Date 2021/4/28 9:06
 */
@FunctionHint(output = @DataTypeHint("ROW<source string, ct bigint>"))
public class KeywordProductUdtf extends TableFunction<Row> {
    public void eval(Long clickCT, Long cartCt, Long orderCt){
        if(clickCT > 0){
            collect(Row.of(GmallConstant.KEYWORD_CLICK, clickCT));
        }
        if(cartCt > 0){
            collect(Row.of(GmallConstant.KEYWORD_CART, cartCt));
        }
        if(orderCt > 0){
            collect(Row.of(GmallConstant.KEYWORD_ORDER, orderCt));
        }
        
    }
}
